﻿using CentralVacuum.Common;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CentralVacuum.Froms
{
    public partial class FLocker : UIForm
    {
        private int gButtonFlag = 0;
        public FLocker()
        {
            InitializeComponent();
        }

        private void FLocker_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void FLocker_FormClosed(object sender, FormClosedEventArgs e)
        {
            timer1.Enabled = false;
        }

        private void uiTextBox1_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2334", this.backgroundWorker1);
            uiTextBox2.Focus();
        }

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            gButtonFlag = 1;
            Thread.Sleep(500);//设置采集周期
        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            gButtonFlag = 0;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (gButtonFlag == 1)
                return;

            //画面显示
            uiTextBox2.Text = ControlAttribute.TextBoxRead(uiTextBox2, Global.rData.D2222.ToString());//原料生产总模数
            uiTextBox1.Text = ControlAttribute.TextBoxRead(uiTextBox1, Global.rData.D2334.ToString());//设定锁机次数
        }

    }
}
